package cn.easyutil.project.base.bean;

import cn.easyutil.project.base.sqlExecuter.annotation.TableId;
import cn.easyutil.project.base.sqlExecuter.annotation.TableIgnore;
import cn.easyutil.project.base.sqlExecuter.annotation.TableField;
import cn.easyutil.util.javaUtil.JsonUtil;
import cn.easyutil.util.javaUtil.ObjectUtil;
import io.swagger.annotations.ApiModelProperty;

/**
 *    
 * 类名：BizBean   
 * 类描述： 业务处理基础javaBean
 * 创建人：byron
 * 修改人：byron
 * 修改时间：2017年3月3日 下午1:31:47   
 * 修改备注：   
 * @version 1.0.0   
 *    
 */
public class BizBean extends BaseBean {

	private static final long serialVersionUID = 8359088677417040990L;

	
	@TableIgnore
	@ApiModelProperty(value="mongo主键",hidden=true)
	protected String _id;
	
	/** 数据id */
	@TableId
	@TableField("id")
	protected Long id;

	/** 创建时间 */
	@TableField("create_time")
	@ApiModelProperty(value="创建/生成时间",example = "${time}")
    protected Long createTime;

	@TableIgnore
	@ApiModelProperty(hidden=true)
    protected Page page;

    @TableField("update_time")
    @ApiModelProperty(hidden=true)
    protected Long updateTime;

    @TableField("deleted")
    @ApiModelProperty(hidden=true)
	private Integer deleted;

	/** 创建时间 */
	@TableField("create_time_zero")
	@ApiModelProperty(hidden=true)
	protected Long createTimeZero;

	/** 清空创建时间和修改时间字段 */
	public void cleanInitTimeValue() {
		createTime = null;
		updateTime = null;
	}

	/** 清空所有初始字段 */
	public void cleanInitValue() {
		cleanInitTimeValue();
		ObjectUtil.cleanInitValue(this);
	}
	
	@Override
	public int hashCode() {
		if(id == null) {
			return super.hashCode();
		}
		return id.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		BizBean other = (BizBean) obj;
		if (id!=null && id.equals(other.id)) {
			return true;
		}
		return super.equals(obj) || JsonUtil.beanToJson(obj).equals(JsonUtil.beanToJson(this));
	}

	public Integer getDeleted() {
		return deleted;
	}

	public void setDeleted(Integer deleted) {
		this.deleted = deleted;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}

	public Long getUpdateTime() {
		return updateTime;
	}
	
	public String get_id() {
		return _id;
	}

	public void set_id(String _id) {
		this._id = _id;
	}

	public void setUpdateTime(Long updateTime) {
		this.updateTime = updateTime;
	}

	public Long getCreateTimeZero() {
		return createTimeZero;
	}

	public void setCreateTimeZero(Long createTimeZero) {
		this.createTimeZero = createTimeZero;
	}

	public static String getSqlFieldCreateTime(){
		return "create_time";
	}
	public static String getSqlFieldDeleted(){
		return "deleted";
	}
	public static String getSqlFieldUpdateTime(){
		return "update_time";
	}
	public static String getSqlFieldId(){
		return "id";
	}
}
